package net.siufung.security.base;

import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;
import java.util.Map;

/**
 * 会话用户
 * @author 陈建峰
 * @since 2021/11/12 1:29 下午
 */
@Getter
public class CurrentUser extends User {

	private static final long serialVersionUID = -1678110152386279758L;
	/**
	 * 用户唯一标识
	 */
	private final String id;

	/**
     * 用户名称
	 */
	private final String name;

    /**
     * 手机号
	 */
	private final String phone;

	/**
	 * 用户组
	 */
	private final CurrentUserGroup userGroup;

	/**
     * 是否超级管理员
	 */
	private final Boolean superState;

	/**
     * 用户初始状态
	 */
	private final Boolean initState;

	/**
	 * 扩展的属性
	 */
	private final Map<String, Object> extra;

	public CurrentUser(
			String username,
			String password,
			boolean enabled,
			boolean accountNonExpired,
			boolean credentialsNonExpired,
			boolean accountNonLocked,
			Collection<? extends GrantedAuthority> authorities,
			String id,
			String name,
			String phone,
			CurrentUserGroup userGroup,
			Boolean superState,
			Boolean initState,
			Map<String, Object> extra) {
		super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
		this.id = id;
		this.name = name;
		this.phone = phone;
		this.userGroup = userGroup;
		this.superState = superState;
		this.initState = initState;
		this.extra = extra;
	}
}
